package com.qf.service.impl;

import com.qf.dao.OperatorRepository;
import com.qf.operators.Operators;
import com.qf.service.Operators2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class Operators2ServiceImpl implements Operators2Service {

    @Autowired
    OperatorRepository operatorRepository;

    /*查询全部信息*/
    public List<Operators> findAll() {
        List<Operators> list = operatorRepository.findAll();
        return list;
    }

    /*id查询信息*/
    @Override
    public Operators findById(Integer id) {
        Optional<Operators> optional = operatorRepository.findById(id);
        if (optional.isPresent()) {
            Operators student = optional.get();
            return student;
        }
        return null;
    }

    /*修改和新增*/
    @Override
    public void updateStudent(Operators operators) {
        operatorRepository.saveAndFlush(operators);

    }
    /*删除*/
    @Override
    public void deleteById(Integer id) {

        operatorRepository.deleteById(id);
    }

}
